<template>
	<view>
		<scroll-view class='bg-white' scroll-y style='height:calc(100vh - 130px)'>
			<view v-if="'4'==detail.state" class="bg-red text-sm padding-xs">
				<text class="cuIcon-info"></text> 拒绝原因：{{detail.rejectReason}}
			</view>
			<view class="padding padding-top-xs">
			<view class='flex'>
				<text class='text-xl text-bold'>{{detail.title}}</text> <!-- {{detail.title}} -->
			</view>
			<view class="flex padding-top-sm">
				<view class="flex-treble">
					<text class="text-red">{{detail.salary}}</text> /月
					<view class="flex margin-top-xs">
						<view class="text-green text-sm padding-xs">{{detail.cityName}}</view>
						<view class="cu-tag radius line-blue">{{detail.dtypeName}}</view>
						<view class="cu-tag radius line-blue">{{detail.dlTypeName}} 驾照</view>
					</view>
				</view>
				<view class="text-right padding-right flex-sub">
					<template v-if="0==detail.state">
						<text class="text-orange">审核中</text>
					</template>
					<template v-else-if="1==detail.state">
						<text class="text-green">展示中</text>
					</template>
					<template v-else-if="3==detail.state">
						<text class="text-gray">已关闭</text>
					</template>
					<template v-else-if="4==detail.state">
						<text class="text-gray">审核拒绝</text>
					</template>
				</view>
			</view>
			
			<view @tap="showModal=true" class="text-center bg-orange text-underline padding-sm text-bold text-black margin-top">
				加急推广，群推送，推荐使用！！！
			</view>

			<view class='padding solid margin-top'>
				<view v-html="detail.content"></view>
			</view>
			<view class='margin'>
				<image v-for="(item,index) in detail.infoPicList" :key="index" :data-img="item.picURL" mode='aspectFit' @click="preview"
				 :src="item.picURL"></image>
			</view>
			<view class="flex">
				<view class="flex-sub text-right">
					联系人：
				</view>
				<view class="flex-treble">
					{{ detail.linkMan }}
				</view>
			</view>
			<view class="flex padding-top">
				<view class="flex-sub text-right">
					联系电话：
				</view>
				<view class="flex-treble">
					{{ detail.phone }}
				</view>
			</view>
			</view>
		</scroll-view>
		<view v-if="'4'!=detail.state" class="flex text-center" style="position: fixed;width: 100%;bottom: 30px;">
			<view class="flex-sub padding-right">
				<button @tap="edit" style="width:90%" class="margin-left cu-btn lg bg-white">编辑</button>
			</view>
			<view class="flex-sub padding-left">
				<template v-if="'3'==detail.state">
					<button @tap="close(1)" style="width:90%" class="margin-right cu-btn lg bg-blue">
						开启展示
					</button>
				</template>
				<template v-else>
					<button @tap="close(3)" style="width:90%" class="margin-right cu-btn lg bg-red">
						关闭展示
					</button>
				</template>
				
			</view>
		</view>
		<member :id="detail.ancId" :showModal="showModal" @close="showModal = false" />
	</view>
</template>

<script>
	import member from '../../components/member.vue'
	export default {
		data() {
			return {
				phoneData: {
					phone: '',
				},
				showModal: false,
				detail: {
					ancId: '',
					areaCode: "",
					cityName: "",
					content: "",
					creId: 6,
					creTm: "",
					dlTypeId: -1,
					dlTypeName: "不限",
					dtypeId: 2,
					dtypeName: "",
					headPortrait: '',
					infoPicList: [],
					infoPicPathArr: '',
					labIDArr: [],
					labList: [],
					linkMan: "王文华",
					phone: "187****3482",
					recruitType: "1",
					salary: '',
					salary1: '',
					salary2: '',
					title: '',
				},
			};
		},
		components: {
			member
		},
		onLoad(option) {
			this.getDetail(option.id);
		},
		methods: {
			edit(){
				let item = this.detail;
				uni.showModal({
					title: '提示',
					content: '重新编辑会下线该信息，重新进入人工审核，是否继续？',
					success: function(res) {
						if (res.confirm) {
							uni.showLoading({
								mask: true,
								title: '请稍候...'
							})
							uni.setStorageSync('ancInfo', item);
							uni.navigateTo({
								url: '/pages/user/pubedit'
							})
						}
					},
				});
			},
			close(state){
				let _this = this;
				let desc = state == 3 ? '关闭' : '开启';
				uni.showModal({
					title: '提示',
					content: `确认${desc}该信息？`,
					success: function(res) {
						if (res.confirm) {
							uni.showLoading({
								mask: true,
								title: '请稍候...'
							})
							_this.baseRequest('api/driver/setState', 'POST', {
								ancId: _this.detail.ancId,
								state: state
							}, function(res, info) {
								uni.hideLoading();
								setTimeout(() => {
									uni.showToast({
										title: '操作成功'
									});
									setTimeout(() => {
										uni.hideToast();
										uni.switchTab({
											url: '/pages/pub/pub'
										})
									}, 1000)
								}, 0);
							});
						}
					},
				});
			},
			reportEv() {
				uni.navigateTo({
					url: '/pages/index/report?id=' + this.detail.ancId
				})
			},

			navTo(type) {
				if (type == "1") {
					uni.switchTab({
						url: '/pages/index/index'
					});
				}
				if (type == "2") {
					uni.switchTab({
						url: '/pages/pub/pub'
					})
				}

			},
			preview() {

			},
			phoneCall(ancId) {
				let _this = this;
				this.baseRequest('api/driver/info/phone', 'GET', {
					ancId
				}, function(res, info) {
					if (res) {
						_this.phoneData = res;
						_this.detail.phone = _this.phoneData.phone;
					} else {
						uni.showToast({
							icon: 'none',
							title: info
						})
					}
				}, function(){
					uni.showModal({
						title: '提示',
						content: '积分不够，赶快去充值吧?',
						success: function(res) {
							if (res.confirm) {
								uni.navigateTo({
									url: '/pages/component/pay'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
				});
			},
			getDetail(ancId) {
				let _this = this;
				this.baseRequest('api/driver/info/detail/history', 'GET', {
					ancId
				}, function(res, info) {
					_this.detail = res;
				});
			},
		}
	}
</script>
